package com.hua.demo.edu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hua.demo.edu.entity.Teacher;
import com.hua.demo.edu.mapper.TeacherMapper;
import com.hua.demo.edu.service.TeacherService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 讲师 服务实现类
 * </p>
 *
 * @author huazi
 * @since 2021-11-10
 */
@Service
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> implements TeacherService {
    @Override
    public Map<String, Object> gettecherfrontlist(Page<Teacher> teacherPage) {
        QueryWrapper<Teacher> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id");
        baseMapper.selectPage(teacherPage,wrapper);
        List<Teacher> records = teacherPage.getRecords();
        long current = teacherPage.getCurrent();
        long pages = teacherPage.getPages();
        boolean next = teacherPage.hasNext();
        boolean previous = teacherPage.hasPrevious();
        long size = teacherPage.getSize();
        long total = teacherPage.getTotal();
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("size",size);
        hashMap.put("total",total);
        hashMap.put("current",current);
        hashMap.put("pages",pages);
        hashMap.put("next",next);
        hashMap.put("previous",previous);
        hashMap.put("items",records);
        return hashMap;
    }
}
